package pl.edu.pw.ee.buildcity.commons;

import org.joda.time.format.PeriodFormatter;
import org.joda.time.format.PeriodFormatterBuilder;

/**
 * @author Mateusz
 * @since 2010-04-05
 */
public class Utils {

	public static PeriodFormatter getPeriodFormatter() {

		PeriodFormatter formatter = new PeriodFormatterBuilder()
				.appendDays()
				.appendSuffix(" d.")
				.appendSeparator(", ")
				.appendHours()
				.appendSuffix(" h.")
				.appendSeparator(", ")
				.printZeroAlways()
				.appendMinutes()
				.appendSuffix(" min.")
				.toFormatter();
		return formatter;
	}

	public static PeriodFormatter getDurationFormatter() {

		PeriodFormatter formatter = new PeriodFormatterBuilder()
				.appendHours()
				.appendSuffix(" h.")
				.appendSeparator(", ")
				.appendMinutes()
				.appendSuffix(" min.")
				.appendSeparator(", ")
				.printZeroRarelyLast()
				.appendSecondsWithOptionalMillis()
				.appendSuffix(" s.")
				.toFormatter();

		return formatter;
	}

}
